import { defineConfig, presetUno } from "unocss";
import presetWeapp from "unocss-preset-weapp";
const remRE = /^-?[\.\d]+rem$/;

export default defineConfig({
  presets: [presetUno()],
  theme: {
    // 解决小程序不支持 * 选择器
    preflightRoot: ["page,::before,::after"],
  },
  postprocess(util) {
    // 自定义rem 转 rpx
    util.entries.forEach((i) => {
      const value = i[1];
      if (value && typeof value === "string" && remRE.test(value))
        i[1] = `${value.slice(0, -3) * 16 * 2}rpx`;
    });
  },
});
